//
//  HNSH_RewardPoolHeaderView.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/3/3.
//

#import "HNSH_RewardPoolHeaderView.h"

@interface HNSH_RewardPoolHeaderView ()

/* bgView */
@property (nonatomic, strong) UIView *bgView;
/* leftTitleLabel */
@property (nonatomic, strong) UILabel *leftTitleLabel;
/* leftLabel */
@property (nonatomic, strong) UILabel *leftLabel;
/* rightTitleLabel */
@property (nonatomic, strong) UILabel *rightTitleLabel;
/* rightLabel */
@property (nonatomic, strong) UILabel *rightLabel;

/* lineView */
@property (nonatomic, strong) UIView *lineView;

/* jfTitleLabel */
@property (nonatomic, strong) UILabel *jfTitleLabel;
/* jfLabel */
@property (nonatomic, strong) UILabel *jfLabel;

@end

@implementation HNSH_RewardPoolHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self configUI];
    }
    return self;
}

//MARK: Setter Methods
- (void)setDic:(NSDictionary *)dic{
    _dic = dic;
    
    self.jfLabel.text = [NSString stringWithFormat:@"%.2f", [dic[@"balance"] doubleValue]];
    self.jfTitleLabel.text = [NSString stringWithFormat:@"%@", dic[@"balance_label"]];
}

- (void)configUI {
    
    [self addSubview:self.jfLabel];
    [self addSubview:self.jfTitleLabel];
    
    [self.jfTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.mas_equalTo(0);
        make.height.mas_equalTo(25);
    }];
    
    [self.jfLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.mas_centerX);
        make.top.mas_equalTo(18);
        make.height.mas_equalTo(67);
    }];
    
    [self addSubview:self.bgView];
    
    [self.bgView addSubview:self.leftTitleLabel];
    [self.bgView addSubview:self.leftLabel];
    [self.bgView addSubview:self.rightTitleLabel];
    [self.bgView addSubview:self.rightLabel];
    [self.bgView addSubview:self.lineView];
    [self.leftTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.height.mas_equalTo(25);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(self.bgView.width/2);
    }];
    
    [self.leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(53);
        make.height.mas_equalTo(33);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(self.bgView.width/2);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bgView.mas_centerX);
        make.top.mas_equalTo(26);
        make.bottom.mas_equalTo(-26);
        make.width.mas_equalTo(1);
    }];
    
    [self.rightTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20);
        make.height.mas_equalTo(25);
        make.left.mas_equalTo(self.bgView.width/2);
        make.width.mas_equalTo(self.bgView.width/2);
    }];
    
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(53);
        make.height.mas_equalTo(33);
        make.left.mas_equalTo(self.bgView.width/2);
        make.width.mas_equalTo(self.bgView.width/2);
    }];
    
}

#pragma mark lazy
- (UILabel *)jfTitleLabel {
    if (!_jfTitleLabel) {
        _jfTitleLabel = [[UILabel alloc]init];
        _jfTitleLabel.text = @"本期累计汇宝";
        _jfTitleLabel.textColor = [UIColor colorWithHexString:@"#F7E9C6"];
        _jfTitleLabel.font = [UIFont systemFontOfSize:18];
        _jfTitleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _jfTitleLabel;
}

- (UILabel *)jfLabel {
    if (!_jfLabel) {
        _jfLabel = [[UILabel alloc]init];
        _jfLabel.text = @"100";
        _jfLabel.textColor = [UIColor appWhiteLabelColor];
        _jfLabel.font = [UIFont systemFontOfSize:48];
        _jfLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _jfLabel;
}
    
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 97, kScreenWidth-40, 108)];
        _bgView.backgroundColor = [UIColor clearColor];
        _bgView.layer.cornerRadius = 10;
        _bgView.layer.masksToBounds = YES;
        _bgView.layer.borderColor = [[UIColor colorWithHexString:@"#F7E9C6"] CGColor];
        _bgView.layer.borderWidth = 1.0f;
    }
    return _bgView;
}
    
- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithHexString:@"#F7E9C6"];
    }
    return _lineView;
}

- (UILabel *)leftTitleLabel {
    if (!_leftTitleLabel) {
        _leftTitleLabel = [[UILabel alloc]init];
        _leftTitleLabel.text = @"昨日累计汇宝";
        _leftTitleLabel.textColor = [UIColor colorWithHexString:@"#F7E9C6"];
        _leftTitleLabel.font = [UIFont systemFontOfSize:18];
        _leftTitleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _leftTitleLabel;
}

- (UILabel *)leftLabel {
    if (!_leftLabel) {
        _leftLabel = [[UILabel alloc]init];
        _leftLabel.text = @"434.00";
        _leftLabel.textColor = [UIColor appWhiteLabelColor];
        _leftLabel.font = [UIFont systemFontOfSize:24];
        _leftLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _leftLabel;
}

    
- (UILabel *)rightTitleLabel {
    if (!_rightTitleLabel) {
        _rightTitleLabel = [[UILabel alloc]init];
        _rightTitleLabel.text = @"已奖励汇宝总额";
        _rightTitleLabel.textColor = [UIColor colorWithHexString:@"#F7E9C6"];
        _rightTitleLabel.font = [UIFont systemFontOfSize:18];
        _rightTitleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _rightTitleLabel;
}

- (UILabel *)rightLabel {
    if (!_rightLabel) {
        _rightLabel = [[UILabel alloc]init];
        _rightLabel.text = @"100";
        _rightLabel.textColor = [UIColor appWhiteLabelColor];
        _rightLabel.font = [UIFont systemFontOfSize:24];
        _rightLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _rightLabel;
}


@end
